000100*AAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCC
000200*                      
000300*                    (SEQ)                        (SEQ)                  
000400 IDENTIFICATION              DIVISION.
000500 PROGRAM-ID.                 STTTEST.
000600*AUTHOR.                     KENJI KIMURA.
000700 ENVIRONMENT                 DIVISION.
000800 CONFIGURATION               SECTION.
000900 INPUT-OUTPUT                SECTION.
001000 FILE-CONTROL.
001100*                        
001200*ACMFILE
001300*ACMRECNAME=I-RECORD
001400     SELECT INP-FILE ASSIGN TO "dbtests"
001500       ORGANIZATION IS INDEXED
001600       ACCESS MODE     DYNAMIC
001700       RECORD KEY   IS I-ID.
001800 DATA                        DIVISION.
001900 FILE                        SECTION.
002000*                    
002100 FD  INP-FILE.
002200 COPY "I_RECORD.cbl".
002300 WORKING-STORAGE             SECTION.
002400 01  SOME-AREA.
002500     05  I-COUNTER           PIC 9(05).
002600     05  O-COUNTER           PIC 9(05).
002700     05  END-FLG             PIC 9(01)  VALUE  ZERO.
002800 PROCEDURE                   DIVISION.
002900*              
003000 MAIN                        SECTION.
003100     PERFORM   INIT.
003200     PERFORM   FL-OPEN.
003300     PERFORM  INP-READ.
003400*                                                      
003500     PERFORM   UNTIL  END-FLG  NOT  =  ZERO
003600*                 OR  I-COUNTER     > 10000
003700        PERFORM  OUT-WRITE
003800        PERFORM  INP-READ
003900     END-PERFORM.
004000     PERFORM   FL-CLOSE.
004100     PERFORM   TERM.
004200     STOP RUN.
004300*              
004400 INIT                        SECTION.
004500     DISPLAY   "PROGRAM STARTING.".
004600     EXIT.
004700*                      
004800 FL-OPEN                     SECTION.
004900     OPEN   INPUT  INP-FILE.
005000     MOVE  5000    TO  I-ID.
005100     START INP-FILE
005200       KEY IS = I-ID
005300     INVALID KEY MOVE 10001   TO  I-COUNTER
005400     END-START.
005500     EXIT.
005600*                  
005700 INP-READ                    SECTION.
005800     READ INP-FILE NEXT
005900       AT END  MOVE 1 TO END-FLG
006000     END-READ.
006100     IF  END-FLG  =  ZERO
006200*                                                                
006300         ADD  1              TO  I-COUNTER
006400     END-IF.
006500     EXIT.
006600*                  
006700 OUT-WRITE                   SECTION.
006800     DISPLAY  I-RECORD.
006900     ADD  1                  TO  O-COUNTER.
007000     EXIT.
007100*                              
007200 FL-CLOSE                    SECTION.
007300     CLOSE  INP-FILE.
007400     EXIT.
007500*              
007600 TERM                        SECTION.
007700     DISPLAY   "PROGRAM NORMALLY TERMINATED.".
007800     DISPLAY   "INPUT-COUNT:" I-COUNTER.
007900     DISPLAY   "OUTPUT-COUNT:" O-COUNTER.
008000     EXIT.
